package frsf.cidisi.exercise.laberinto.situationCalculus;

import frsf.cidisi.faia.agent.Agent;
import frsf.cidisi.faia.agent.situationcalculus.SituationCalculusPerception;
import frsf.cidisi.faia.environment.Environment;

public class AgenteLaberintoPerception extends SituationCalculusPerception {
	
	static public final int PARED = 0;
	static public final int NADA = 1;
	static public final int LLAVE = 2;
	static public final int SALIDA = 3;
	static public final int CERROJO = 4;
	
	//TODO: Setup Sensors
	private int posicion_x;
	private int posicion_y;
	
	private int sensor_norte;
	private int sensor_este;
	private int sensor_sur;
	private int sensor_oeste;
	private int sensor_objeto;
	
    public AgenteLaberintoPerception() {
        super();
        sensor_objeto = 1;        		
    }

    @Override
    public void initPerception(Agent agent, Environment environment) {
    	
        // TODO Auto-generated method stub
    }

    @Override
    public String toString() {
        StringBuffer perceptionString = new StringBuffer("percepcion([");

        // Agent position
        perceptionString.append(this.getposicion_x());
        perceptionString.append(",");
        perceptionString.append(this.getposicion_y());
        perceptionString.append("],");    
        
        // Adjacent cells
        perceptionString.append(this.convertCellState(this.sensor_norte));
        perceptionString.append(",");
        perceptionString.append(this.convertCellState(this.sensor_este));
        perceptionString.append(",");
        perceptionString.append(this.convertCellState(this.sensor_sur));
        perceptionString.append(",");
        perceptionString.append(this.convertCellState(this.sensor_oeste));
        perceptionString.append(",");
        perceptionString.append(this.convertCellState(this.sensor_objeto));
        perceptionString.append(")");

        return perceptionString.toString();
    }
    
    private String convertCellState(int cellState) {
        String result = null;

        switch (cellState) {
	        case PARED:
	        	result = "pared";
	        	break;
	        case NADA:
	        	result = "nada";
	        	break;
	        case LLAVE:
	        	result = "llave";
	        	break;
	        case SALIDA:
	        	result = "salida";
	        	break;
	        case CERROJO:
	        	result = "cerrojo";
	        	break;
	        default:
	        	break;
        }
        return result;
    }
    
    
     public int getposicion_x(){
        return posicion_x;
     }
     public void setposicion_x(int arg){
        this.posicion_x = arg;
     }
     public int getposicion_y(){
        return posicion_y;
     }
     public void setposicion_y(int arg){
        this.posicion_y = arg;
     }
     public int getsensor_norte(){
        return sensor_norte;
     }
     public void setsensor_norte(int arg){
        this.sensor_norte = arg;
     }
     public int getsensor_este(){
        return sensor_este;
     }
     public void setsensor_este(int arg){
        this.sensor_este = arg;
     }
     public int getsensor_sur(){
        return sensor_sur;
     }
     public void setsensor_sur(int arg){
        this.sensor_sur = arg;
     }
     public int getsensor_oeste(){
        return sensor_oeste;
     }
     public void setsensor_oeste(int arg){
        this.sensor_oeste = arg;
     }

	public int getSensor_objeto() {
		return sensor_objeto;
	}

	public void setSensor_objeto(int sensorObjeto) {
		sensor_objeto = sensorObjeto;
	}

}
